package org.itheima.googleplay.ui.holder;

import org.itheima.googleplay.R;
import org.itheima.googleplay.bean.AppInfoBean;
import org.itheima.googleplay.utils.BitmapHelper;
import org.itheima.googleplay.utils.Constants;
import org.itheima.googleplay.utils.StringUtils;
import org.itheima.googleplay.utils.UIUtils;

import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;

import android.view.View;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;

/**
 * @包名: org.itheima.googleplay.ui.holder
 * @类名: AppDetailInfoHolder
 * @作者: 肖琦
 * @创建时间 : 2015-3-24 上午8:34:42
 * 
 * @描述: 应用详情页面-信息部分
 * 
 * @SVN版本: $Rev: 20 $
 * @更新人: $Author: xq $
 * @更新时间: $Date: 2015-03-24 16:01:24 +0800 (星期二, 24 三月 2015) $
 * 
 * @更新描述:
 */

public class AppDetailInfoHolder extends BaseHolder<AppInfoBean>
{

	@ViewInject(R.id.app_detail_info_iv_icon)
	private ImageView	mIvIcon;

	@ViewInject(R.id.app_detail_info_rb_star)
	private RatingBar	mRbStar;

	@ViewInject(R.id.app_detail_info_tv_downloadnum)
	private TextView	mTvDownloadNum;

	@ViewInject(R.id.app_detail_info_tv_size)
	private TextView	mTvSize;

	@ViewInject(R.id.app_detail_info_tv_name)
	private TextView	mTvName;

	@ViewInject(R.id.app_detail_info_tv_time)
	private TextView	mTvTime;

	@ViewInject(R.id.app_detail_info_tv_version)
	private TextView	mTvVersion;

	@Override
	protected View initView()
	{
		View view = View.inflate(UIUtils.getContext(), R.layout.app_detail_info, null);

		// View注入
		ViewUtils.inject(this, view);

		return view;
	}

	@Override
	protected void refreshUI(AppInfoBean data)
	{
		// 设置文本
		mTvDownloadNum.setText(UIUtils.getString(R.string.app_detail_info_downloadnum, data.downloadNum));// 下载量
		mTvName.setText(data.name);
		mTvSize.setText(UIUtils.getString(R.string.app_detail_info_size, StringUtils.formatFileSize(data.size)));// 大小
		mTvTime.setText(UIUtils.getString(R.string.app_detail_info_date, data.date));
		mTvVersion.setText(UIUtils.getString(R.string.app_detail_info_version, data.version));

		// 设置star
		mRbStar.setRating(data.stars);

		// 图片设置
		mIvIcon.setImageResource(R.drawable.ic_default);
		// 图片加载
		BitmapHelper.display(mIvIcon, Constants.BASE_IMAGE_URL + data.iconUrl);

	}

}
